/**
 *
 * 对象管理类
 * @author 
 *
 */
class Group {
    public static selectedItem:any;
    public static selectedIcon: any;
    
	public constructor() {
	}
	
    public static selectItem(item:any):void{
        //重选还是反选
        if (Group.selectedItem){
            if (Group.selectedItem == item){
                Group.selectedItem.reselectItem();
                return;
            }
            Group.selectedItem.deselectItem();
        }
        
        //选中
        Group.disposeIcon();
        Group.selectedItem = item;
        if (Group.selectedItem){
            Group.selectedItem.selectItem();
            //选中音效
            SoundManager.playEffect("select");
        }
    }
    
    public static dispose():void{
        Group.selectedItem = null;
    }
    
    //icon选择
    
    public static selectIcon(icon: any): void {
        
        //重选还是反选
        if(Group.selectedIcon) {
            if(Group.selectedIcon == icon) {
                Group.selectedIcon.reselectIcon();
                return;
            }
            Group.selectedIcon.deselectIcon();
        }
        
        //选中
        Group.selectedIcon = icon;
        if(Group.selectedIcon) {
            Group.selectedIcon.selectIcon();
            //选中音效
            SoundManager.playEffect("select");
        }
    }

    public static disposeIcon(): void {
        if(Group.selectedIcon==null)
            return
        Group.selectedIcon.deselectIcon();
        Group.selectedIcon = null;
    }
}

